[Ruby] OpenSSL verify certificate from own CA

Posted by sardaukar on Stack Overflow See other posts from Stack Overflow or by sardaukar
Published on 2009-03-31T13:55:08Z Indexed on 2010/05/10 13:44 UTC
Read the original article Hit count: 490

Filed under:
|
|

Hello all and thanks for your time reading this.

I need to verify certificates issued by my own CA, for which I have a certificate. How can I do the equivalent to openssl's

openssl verify -CAfile

in Ruby code? The RDoc for OpenSSL is not very helpful in this regard. I've tried:

require 'openssl'

ca = OpenSSL::X509::Certificate.new(File.read('ca-cert.pem'))

lic = OpenSSL::X509::Certificate.new(File.read('cert.pem'))

puts lic.verify( ca )

but I get:

test.rb:7:in `verify': wrong argument (OpenSSL::X509::Certificate)!
(Expected kind of OpenSSL::PKey::PKey) (TypeError)
  from test.rb:7

I can't even find "verify" in the OpenSSL Rdoc at http://www.ruby-doc.org/stdlib/libdoc/openssl/rdoc/index.html.

Any help is appreciated. Thanks again!

© Stack Overflow or respective owner

Related posts about ruby

Related posts about openssl